<?php
/**
 * Created by PhpStorm.
 * User: xiaomage
 * Date: 2020/12/14
 * Time: 16:35
 */

namespace app\system\controller;

use common\ApiReturn;
use common\data\DataToolbar;
use common\data\DataView;
use component\system\system_action\SystemAction;
use component\system\system_message\SystemMessage;
use component\system\system_role\SystemRole;
use component\system\system_user\SystemUser;
use component\system\system_user_auth\SystemUserAuth;
use component\system\system_user_login\SystemUserLogin;

class Error extends System
{
    public function __call($name, $arguments)
    {
        $view = request()->controller();

        $lists = [
            'SystemUser' => SystemUser::class,
            'SystemUserAuth' => SystemUserAuth::class,
            'SystemRole' => SystemRole::class,
            'SystemLogin' => SystemUserLogin::class,
            'SystemAction' => SystemAction::class,
            'SystemMessage' => SystemMessage::class,
        ];

        $dateView = $lists[$view] ?? '';
        if ($dateView) {
            if (is_string($lists[$view])) {
                $dateView = new DataView($dateView);
            }
            $toolbar = new DataToolbar($dateView);
            return $toolbar->response();
        }

        return ApiReturn::error('尚未识别的api信息，请检查', null, SYSTEM_MANAGER_DATA_NOT_FOUND);
    }
}